function deepClone(obj, hash = new Map()) {
  if (obj === null) {
    return null;
  }
  if (obj instanceof Date) {
    return new Date(obj);
  }
  if (obj instanceof RegExp) {
    return new RegExp(obj);
  }
  if (typeof obj !== "object") {
    return obj;
  }
  // 加一个缓存，如果有就直接返回了
  if (hash.has(obj)) {
    return hash.get(obj);
  }

  let resObj = Array.isArray(obj) ? [] : {};

  // 可以获取到 Symbol 属性的值
  Reflect.ownKeys(obj).forEach((key) => {
    resObj[key] = deepClone(obj[key], hash);
  });
}

let a = { f: 10 };
let b = new Date();
let c = /\[A-Z]/;
let d = null;
let e = "222";
const obja = deepClone(a);
const objb = deepClone(b);
const objc = deepClone(c);
const objd = deepClone(d);
const obje = deepClone(e);

console.log(obja);
console.log(objb);
console.log(objc);
console.log(obje);
